package com.googlecode.perfectable.prosperable.channel;

import org.apache.catalina.websocket.StreamInbound;

import com.googlecode.perfectable.eventable.routing.Sink;
import com.googlecode.perfectable.eventable.routing.Source;
import com.googlecode.perfectable.prosperable.message.ClientMessage;
import com.googlecode.perfectable.prosperable.message.ServerMessage;

public class ChannelFactory {
	private final MessageSerializer serializer;

	public ChannelFactory(Iterable<Class<? extends ServerMessage>> serverClasses,
			Iterable<Class<? extends ClientMessage>> clientClasses) {
		this.serializer = new StandardMessageSerializer(serverClasses, clientClasses);
	}

	public StreamInbound createChannel(Sink<ClientMessage> inbound, Source<ServerMessage> outbound) {
		return new ChannelStreamInbound(outbound, inbound, this.serializer);
	}
}
